$(function() {
	admin.userWithdraw.init();
});
Namespace('admin.userWithdraw', {
	init : function() {
		easyui.util.initDatagrid('#datagrid', {
			onDblClickRow : function() {
			}
		});
	},
	query : function() {
		if (!$('#query-form').form('validate'))
			return;
		var data = $('#query-form').form('jsonObject');
		$('#datagrid').datagrid('load', data);
	},
	confirm:function(id) { //确认
		if(!$('#data-form').form('validate')) return;
		if (id != null) {
			$.messager.confirm('信息提示', "确定已经提现?", function (success) {
				if (!success) {
					return;
				}
	            var url = contextPath + '/user/withdraw/confirm';
				$.post(url, {id:id}, function (result) {
					if (result.code == 1) {
						top.showInfo('操作成功');
						  admin.userWithdraw.query();
					} else {
						top.showInfo(result.msg);
					}
				});

			});
		}
	},
	moneyLog:function(userId) { //确认
		if(null!=userId&&''!=userId){
			 top.addTab(userId,'用户-交易流水', contextPath+'/user/money/log/userMoneyList/' + userId);
		}
	},
	paying:function(id) { //确认付款中
		if(!$('#data-form').form('validate')) return;
		if (id != null) {
			$.messager.confirm('信息提示', "确定提现中?", function (success) {
				if (!success) {
					return;
				}
	            var url = contextPath + '/user/withdraw/paying';
				$.post(url, {id:id}, function (result) {
					if (result.code == 1) {
						top.showInfo('操作成功');
						  admin.userWithdraw.query();
					} else {
						top.showInfo(result.msg);
					}
				});

			});
		}
	},
	cancle:function(id) { //确认付款中
		if(!$('#data-form').form('validate')) return;
		if (id != null) {
			$.messager.prompt('提示:','驳回信息',function(remark){
					if(null!=remark){
						 var url = contextPath + '/user/withdraw/cancle';
							$.post(url, {id:id,remark:remark}, function (result) {
								if (result.code == 1) {
									top.showInfo('操作成功');
									  admin.userWithdraw.query();
								} else {
									top.showInfo(result.msg);
								}
							});
					}
			})
		}
	},
	export2Excel : function() {//导出excel
		var url = contextPath + '/user/withdraw/export2Excel';
		var type = $('#type').val();
		var status = $('#status').val();
		var userNick = $('#userNick').val();
		var endAtStr = $("input[name=endAtStr]").val();//$('#endAtStr').val();
		var startAtStr = $("input[name=startAtStr]").val();//$('#startAtStr').val();
		var params ={};
		var paramstr ="";
		if(type!='' && type!=null){
			paramstr+="&type="+type;
		}
		if(status!='' && status!=null){
			paramstr+="&status="+status;
		}
		if(userNick!='' && userNick!=null){
			paramstr+="&userNick="+userNick;
		}
		if(startAtStr!='' && startAtStr!=null){
			paramstr+="&startAtStr="+startAtStr;
		}
		if(endAtStr!='' && endAtStr!=null){
			paramstr+="&endAtStr="+endAtStr;
		}
		if(paramstr!=''){
			url += "?"+paramstr;
		}
		window.open(url,"");
		/*
		$.get(url,params,function(result) {
			if(result.code==1) {
				top.showInfo('导出完成!');
			} else {
				top.showInfo('导出失败!'+result.msg);
			}
		});
		*/
	}
});